package canss.webservice.servlets;


import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import canss.supports.basic;
import canss.webservice.service.PortalIntraWebServiceControl;


import canss.webservice.service.PortalIntraWebServiceControlBean;

/**
 * Servlet implementation class for Servlet: svtEditFeed
 *
 */
 public class svtAjaxDeleteFeed extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
   static final long serialVersionUID = 1L;
   
    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public svtAjaxDeleteFeed() {
		super();
	}   	
	
	PortalIntraWebServiceControl control; //control = (control==null)?new PortalIntraWebServiceControlBean():control;
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		doPost(request, response);
	}  	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		response.setContentType("text/html; charset=UTF-8");
		StringBuffer retstr = new StringBuffer();
		PrintWriter out = response.getWriter();
		
		try
		{
			String _pid = request.getParameter("_pid");
			String _mid = request.getParameter("_mid");
			String _feeduri = request.getParameter("_feeduri");
			
			out.write(_pid);
			out.write(_mid);
			out.write(_feeduri);
			
			control = (control==null)?new PortalIntraWebServiceControlBean():control;
			control.deleteFeed(_pid, _mid, _feeduri);
			
		} catch (RuntimeException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
			retstr.append(e.toString()+"<br/>");
		}
		out.write(retstr.toString());
		
		String _rurl = request.getParameter("_rurl");
		if( !basic.isEmpty(_rurl) )
		{
			response.sendRedirect(response.encodeRedirectURL(_rurl));
		}
	}   	  	    
}